//!
//! Copyright (c) 2024-2999 北京心月狐科技有限公司 All rights reserved.
//!
//! https://www.mxxshop.com
//!
//! Licensed 并不是自由软件，未经许可不能去掉 MxxShop 相关版权
//!
//! 版权所有，侵权必究！
//!


use rbatis::rbdc::DateTime;
use serde::{Deserialize, Serialize};
use crate::modules::product::entity::favorites_entity::Favorites;

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FavoritesSaveRequest {
    /// 商品id
    pub product_id: Option<u64>,
    /// 用户id
    pub user_id: Option<u64>,
}

impl From<FavoritesSaveRequest> for Favorites {
    fn from(request: FavoritesSaveRequest) -> Self {
        Self {
            id: None,
            product_id: request.product_id,
            user_id: request.user_id,
            create_time: Option::from(DateTime::now()),
        }
    }
}


#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct QueryPageRequest {
    /// 用户id
    pub user_id: Option<u64>,
    // 当前页码数
    pub page_num: Option<u64>,
    // 每页条数
    pub page_size: Option<u64>,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct QueryPageBO {
    /// 用户id
    pub user_id: Option<u64>,
    // 当前页码数
    pub page_num: Option<u64>,
    // 每页条数
    pub page_size: Option<u64>,
}